import { TaskDefinedLog } from '@/service/modules/task-manage/types'
import { NFormItem, NInputNumber } from 'naive-ui'
import { VNode, h } from 'vue'

export function useFailed(taskLog: TaskDefinedLog): VNode[] {
  return [
    h(
      NFormItem,
      {
        path: 'failRetryTimes',
        label: window.$t('taskManage.failRetryTimes')
      },
      h(
        NInputNumber,
        {
          value: taskLog.taskParams.failRetryTimes,
          onUpdateValue: (v: number | null) => {
            taskLog.taskParams.failRetryTimes = v
          },
          size: 'tiny',
          style: 'width:120px',
          min: 0,
          max: 5,
          default: 0
        },
        { suffix: () => window.$t('taskManage.times') }
      )
    ),
    h(
      NFormItem,
      {
        path: 'failRetryInterval',
        label: window.$t('taskManage.failRetryInterval')
      },
      h(
        NInputNumber,
        {
          value: taskLog.taskParams.failRetryInterval,
          onUpdateValue: (v: number | null) => {
            taskLog.taskParams.failRetryInterval = v
          },
          size: 'tiny',
          style: 'width:120px',
          min: 0,
          default: 0
        },
        { suffix: () => window.$t('taskManage.minute') }
      )
    )
  ]
}
